import java.time.Instant;
import java.time.temporal.Temporal;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;

class Statistics
{
    private long battleTime;
    private int turns;
    private Instant battleStartTime;
    private int battleWinner;
    private static Statistics instance;
    
    public Statistics()
    {
        reset();
    }
    
    public void startTimer()
    {
        battleStartTime = Instant.now();
    }
        
    public void stopTimer()
    {
        Instant battleStopTime = Instant.now();
        
        battleTime = ChronoUnit.MILLIS.between(battleStartTime, battleStopTime);
        
    }
    
    public void turn()
    {
        turns++;
    }
    
    public HashMap getResults()
    {
        HashMap <String, Integer> results = new HashMap<String, Integer>();
        
        int time = (int) battleTime / 1000;
        
        results.put("time", time);
        results.put("turns", turns);
        results.put("winner", battleWinner);
        
        return results;
    }
            
    
    public void reset()
    {
        battleTime   = 0;
        turns        = 0;
        battleWinner = -1;
    }
    
    public static Statistics getInstance()
    {
        if (instance == null)
        {
            instance = new Statistics();
        }
        
        return instance;
    }
}